package com.winsdom.entity.customer;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.util.List;

/**
 * 企业客户信息更新请求
 * 用于接收更新企业客户信息的请求参数
 */
@Data
@Schema(name = "CustomerEnterpriseUpdateRequest", description = "企业客户信息更新请求")
public class CustomerEnterpriseUpdateRequest {

    @Schema(description = "客户ID", example = "34", required = true)
    @NotNull(message = "客户ID不能为空")
    private Long customerId;

    @Schema(description = "客户名称", example = "最新的企业8")
    @Size(min = 2, max = 50, message = "客户名称长度为2至50个字符")
    private String customerName;

    @Schema(description = "客户手机号", example = "19942888888")
    @Pattern(regexp = "^1\\d{10}$", message = "手机号格式不正确，应为11位数字且以1开头")
    private String mobilePhone;

    @Schema(description = "统一社会信用码", example = "96678900ILHRW8888")
    @Pattern(regexp = "^[A-Z0-9]{15}$|^[A-Z0-9]{18}$|^[A-Z0-9]{20}$",
            message = "统一社会信用码格式不正确，应为15、18或20位数字或英文")
    private String unifiedSocialCreditCode;

    @Schema(description = "企业性质", example = "合资")
    @Size(max = 50, message = "企业性质长度不能超过50个字符")
    private String enterpriseNature;

    @Schema(description = "经营性质", example = "农业")
    @Size(max = 50, message = "经营性质长度不能超过50个字符")
    private String businessNature;

    @Schema(description = "电子邮箱", example = "updated888888@example.com")
    @Email(message = "邮箱格式不正确")
    @Size(max = 100, message = "邮箱长度不能超过100个字符")
    private String email;

    @Schema(description = "纳税身份", example = "1")
    @Pattern(regexp = "[12]", message = "纳税身份无效，可选值：1,2")
    private String taxIdentity;

    @Schema(description = "是否重点招商引资客户", example = "0")
    @Pattern(regexp = "[01]", message = "是否重点招商引资客户值无效，可选值：0,1")
    private String keyInvestmentCustomer;

    @Schema(description = "开户行", example = "Bank of China")
    @Size(min =4, max = 30, message = "开户行名称长度为4至30个字符")
    private String bankName;

    @Schema(description = "开户行账号", example = "88888888888888")
    @Pattern(regexp = "^\\d{12,25}$", message = "银行账号为12至25位数字")
    private String bankAccount;

    @Schema(description = "注册资金（万元）", example = "188888888.00")
    @DecimalMin(value = "0.01", message = "注册资金不能小于0.01万元")
    @Digits(integer = 10, fraction = 2, message = "注册资金格式不正确，只能输入数字和小数点，保留两位小数")
    private BigDecimal registeredCapital;

    @Schema(description = "企业人数", example = "110")
    @Min(value = 1, message = "企业人数不能小于1")
    @Pattern(regexp = "^\\d+$", message = "企业人数格式不正确，只能是数字")
    private Integer numberOfPeople;

    @Schema(description = "营业执照图片地址", example = "/images/business_license8.jpg")
    @Size(max = 255, message = "图片地址长度不能超过255个字符")
    private String businessLicenseImage;

    @Schema(description = "注册地址区域", example = "[\"浙江省\", \"杭州市\", \"西湖区\"]")
    @Size(max = 100, message = "注册地址区域长度不能超过100个字符")
    private String registrationArea;

    @Schema(description = "注册地址区域码", example = "[\"33\", \"3301\", \"330106\"]")
    @Size(max = 20, message = "注册地址区域码长度不能超过20个字符")
    private String registrationAreaCode;

    @Schema(description = "注册详情地址", example = "Chongqing City, Detailed Address 1")
    @Size(max = 200, message = "注册详情地址长度不能超过200个字符")
    private String registrationDetailedAddress;

    @Schema(description = "办公地址区域", example = "[\"北京市\", \"北京市\", \"朝阳区\"]")
    @Size(max = 100, message = "办公地址区域长度不能超过100个字符")
    private String officeArea;

    @Schema(description = "办公地址区域码", example = "[\"11\", \"1101\", \"110105\"]")
    @Size(max = 20, message = "办公地址区域码长度不能超过20个字符")
    private String officeAreaCode;

    @Schema(description = "办公详情地址", example = "Chongqing City, Detailed Address 2")
    @Size(max = 200, message = "办公详情地址长度不能超过200个字符")
    private String officeDetailedAddress;

    @Schema(description = "联系人信息列表", example = "[{\"contactName\":\"刘东\",\"contactMobile\":\"13567645888\",\"receiveProperties\":[\"金星大厦\"],\"contactEmail\":\"liudong1@example.com\"}]")
    @Valid
    @Size(max = 5, message = "联系人最多5个")
    private List<ContactInfo> contactInfos;

    @Data
    @Schema(name = "CustomerEnterpriseUpdateRequest.ContactInfo", description = "企业联系人信息（更新用）")
    public static class ContactInfo {

        @Schema(description = "联系人ID", example = "1", required = true)
        private Long contactId;

        @Schema(description = "联系人姓名", example = "刘东")
        @Size(min = 4, max = 50, message = "联系人姓名长度为4至50个字符")
        private String contactName;

        @Schema(description = "联系电话", example = "13567645888")
        @Pattern(regexp = "^\\d{4,11}$", message = "联系电话为4至11位数字")
        private String contactMobile;

        @Schema(description = "邮箱", example = "liudong1@example.com")
        @Email(message = "邮箱格式不正确")
        @Size(max = 100, message = "邮箱长度不能超过100个字符")
        private String contactEmail;

        @Schema(description = "接收属性列表", example = "[\"金星大厦\"]")
        private List<String> receiveProperties;
    }
}